<template>
  <div class="tab-bar">
    <router-link to="/" class="tab-item">
      <img src="@/assets/icon/tabar/shouye.png" alt="首页" class="icon">
      <img src="@/assets/icon/tabar/shouyecopy.png" alt="首页" class="icon-active">
      <span>首页</span>
    </router-link>
    <router-link to="/music" class="tab-item">
      <img src="@/assets/icon/tabar/yinle.png" alt="音乐馆" class="icon">
      <img src="@/assets/icon/tabar/yinlecopy.png" alt="音乐馆" class="icon-active">
      <span>音乐馆</span>
    </router-link>
    <router-link to="/my" class="tab-item">
      <img src="@/assets/icon/tabar/wode.png" alt="我的" class="icon">
      <img src="@/assets/icon/tabar/wodecopy.png" alt="我的" class="icon-active">
      <span>我的</span>
    </router-link>
  </div>
</template>

<style lang="scss" scoped>
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 55px;
  background: #fff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #eee;
  z-index: 100;
  border-radius: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transform: none; // 移除 transform - 移到了@supports前面
  
  // 添加移动端适配
  @supports (padding-bottom: env(safe-area-inset-bottom)) {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #666;
    text-decoration: none;
    font-size: 12px;
    position: relative;
    padding: 8px 0;
    transition: all 0.3s ease; // 添加过渡效果

    .icon, .icon-active {
      width: 24px;
      height: 24px;
      margin-bottom: 2px;
    }

    .icon-active {
      display: none;
      position: absolute;
      top: 8px; // 调整位置以适应新的padding
      left: 50%;
      transform: translateX(-50%);
    }

    &.router-link-active {
      color: #31c27c; 
      .icon {
        display: none;
      }

      .icon-active {
        display: block;
      }

      span {
        margin-top: 26px;
      }
    }

    &:hover {
      transform: scale(1.1); // 悬停时略微放大
    }
  }
}
</style>